{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "15ba0ad0",
   "metadata": {},
   "source": [
    "# 1.Head First Python P4"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8d3a2fe5",
   "metadata": {},
   "source": [
    "一定要按规格书写以下代码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c179ec6e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e90a4ae4",
   "metadata": {},
   "source": [
    "# 本项目用到了时间模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "bac59d77",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "490374\n"
     ]
    }
   ],
   "source": [
    "print(datetime.datetime.today().microsecond)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "aff41553",
   "metadata": {},
   "outputs": [],
   "source": [
    "odds = [1, 3, 5, 7, 9, 11,13,15,17,19,\n",
    "       21,23,25,27,29,31,33,35,37,39,\n",
    "       41,43,45,47,49,51,53,55,57,59]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "78131120",
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'datetime.datetime' object has no attribute 'mintute'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "Cell \u001b[1;32mIn [5], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m right_this_minute \u001b[38;5;241m=\u001b[39m datetime\u001b[38;5;241m.\u001b[39mdatetime\u001b[38;5;241m.\u001b[39mtoday()\u001b[38;5;241m.\u001b[39mmintute\n",
      "\u001b[1;31mAttributeError\u001b[0m: 'datetime.datetime' object has no attribute 'mintute'"
     ]
    }
   ],
   "source": [
    "right_this_minute = datetime.datetime.today().mintute"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "28c3697d",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "expected an indented block (3005327870.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Cell \u001b[1;32mIn [6], line 1\u001b[1;36m\u001b[0m\n\u001b[1;33m    if right_this_minute in odds:\u001b[0m\n\u001b[1;37m                                 ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m expected an indented block\n"
     ]
    }
   ],
   "source": [
    "if right_this_minute in odds:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "cc6410dd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "this minute seems a little odd.\n"
     ]
    }
   ],
   "source": [
    "print(\"this minute seems a little odd.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a6cae732",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (4124731095.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Cell \u001b[1;32mIn [8], line 1\u001b[1;36m\u001b[0m\n\u001b[1;33m    else:\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "else:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "2fcdda23",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Not an odd minute.\n"
     ]
    }
   ],
   "source": [
    "print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "b27f2068",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "7904\n"
     ]
    }
   ],
   "source": [
    "print(datetime.datetime.today().microsecond)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4290b875",
   "metadata": {},
   "source": [
    "# 2.1模块--标准库\n",
    "<标准库是python开发团队为满足python用户日常需求而写好的的一些模块，可以直接用import模块\n",
    "1.sys模块\n",
    "2.os模块\n",
    "3.datetime模块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0c51ae25",
   "metadata": {},
   "source": [
    "# 2.2模块--开源模块（pypi.org）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "31993e7d",
   "metadata": {},
   "source": [
    "# 2.3自定义模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "e93c5ef7",
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "f52bb197",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'3.9.12 (main, Apr  4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)]'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sys.version"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "dabca341",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "7866d104",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'C:\\\\Users\\\\花花'"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "dd740ae9",
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "46461ae8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.date(2022, 10, 8)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datetime.date.today()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "95768ccf",
   "metadata": {},
   "source": [
    " #认识下 time模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "7447b4de",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "93d0e646",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=10, tm_mday=8, tm_hour=10, tm_min=38, tm_sec=59, tm_wday=5, tm_yday=281, tm_isdst=0)"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "8629987f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=10, tm_mday=8, tm_hour=10, tm_min=39, tm_sec=27, tm_wday=5, tm_yday=281, tm_isdst=0)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "d0eb5217",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1665196796.2233899"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time() # 时间戳"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "a6eefdb0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "52.80304499730403"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time()/60/60/24/365"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "ab3133f3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1970"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "2022-52"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "940c3983",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=10, tm_mday=8, tm_hour=2, tm_min=41, tm_sec=0, tm_wday=5, tm_yday=281, tm_isdst=0)"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.gmtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "d4afa9ac",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'apple'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "Cell \u001b[1;32mIn [24], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mapple\u001b[39;00m\n",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'apple'"
     ]
    }
   ],
   "source": [
    "import apple"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b7f72de3",
   "metadata": {},
   "source": [
    "# 3.赋值"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2b87fa3d",
   "metadata": {},
   "source": [
    "# 4.变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f76c7dd9",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
